# -*- coding: utf-8 -*-

from PyQt4.QtGui import QDialog
from PyQt4.QtCore import SIGNAL
from PyQt4.Qt import QRect, QDesktopWidget
from ui_editBugKeys import Ui_editBugKeys
from subprocess import *
from mainfunctions import *

class editBugKeys(QDialog):
    def __init__(self, parent=None):
        QDialog.__init__(self, parent)
        self.ui = Ui_editBugKeys()
        self.ui.setupUi(self)
        self.editText = self.ui.textEdit
        
        available_geom = QDesktopWidget().availableGeometry()
        current_geom = self.frameGeometry()
        self.setGeometry(available_geom.width() / 2 - current_geom.width() / 2, available_geom.height() / 2 - current_geom.height() / 2, current_geom.width(), current_geom.height())
        
        self.connect(self.ui.saveBtn, SIGNAL("clicked()"), self.saveBugKeys)
        self.connect(self.ui.cancelBtn, SIGNAL("clicked()"), self.dontSaveBugKeys)

    def writeToBrowser(self, text):
        self.editText.append(text)

    def saveBugKeys(self):
        bugFile = "BugKeys.txt"
        newFile = open(bugFile, 'w')
        newFile.write(self.editText.toPlainText())
        newFile.close()
        self.hide()

    def dontSaveBugKeys(self):        
        self.hide()
